﻿CREATE  proc [dbo].[danhmucCTKT_Sua]  --'23','233','2','2',null,null,null,null
@ma_ctu varchar(255),  
@ten_ctu nvarchar(255),  
@last_ctu nvarchar(255),  
@nhom_ctu nvarchar(255),  
@no_co nvarchar(255),  
@so_ctukt nvarchar(255),  
@tk_trung nvarchar(255),  
@ghichu nvarchar(255)  ,
@ma_ctu_old varchar(255)
as  
if exists(select * from DM_CTu_KT   Where ma_ctu  <>@ma_ctu  and ten_ctu =@ten_ctu   )  
begin  
select ErrCode=0  
end  
else  
begin  

update DM_CTu_KT   set ma_ctu=@ma_ctu_old, ten_ctu =@ten_ctu , last_ctu =@last_ctu ,nhom_ctu =@nhom_ctu,  
      no_co=@no_co ,so_ctukt=@so_ctukt,tk_trung=@tk_trung,ghichu=@ghichu    
  
 WHere ma_ctu  =@ma_ctu_old 
   
select ErrCode=1  
end

select ma_ctu as mactuold from DM_CTu_KT where ma_ctu='2'
--danhmucCTKT_Sua  '23','233','2','2',null,null,null,null,'23'
--danhmucCTKT_loaddulieu

--update DM_CTu_KT  set ma_ctu='2', ten_ctu ='23' , last_ctu ='2' ,nhom_ctu ='2',  
 --     no_co=null ,so_ctukt=null,tk_trung=null,ghichu=null    

 --WHere ma_ctu  ='2'